CC = gcc
OS = LINUX
opt = -Wall 
dbg = -ggdb
EXEC_NAME_REGRESSION = Test_Reg
SRC_TEST= Plateau.c Joueur.c Bonus.c Des.c case.c carte.c listeCarte.c ListeTemp.c ListeTempC.c lireFichier.c Question.c Jeu.c mainTestReg.c

FINAL_TARGET_TXT = student_survivor_txt
SRC_NCURSES = Des.c Bonus.c Jeu.c carte.c Joueur.c lireFichier.c listeCarte.c ListeTemp.c ListeTempC.c Plateau.c Question.c case.c ncurses.c main_ncurses.c
FINAL_TARGET_SDL = student_survivor_sdl
SRC_SDL = Des.c Jeu.c carte.c Joueur.c lireFichier.c listeCarte.c ListeTemp.c Plateau.c Question.c case.c AffichageSdl.c main_sdl.c

DEFINE = -D$(OS) -DJEU_NCURSES

LIBS_TXT = -lncurses -lcdk
LIBS_SDL = -lSDL -lSDL_image -lSDL_ttf -lSDL_gfx

OBJ_FILES 		= obj
SRC_FILES 		= src
SRC_SDL_FILES		= srcSDL
BIN_FILES 		= bin
CFLAGS 			= $(DEFINE)  -Wall -pedantic -ansi -ggdb

test : $(BIN_FILES)/$(EXEC_NAME_REGRESSION)

$(BIN_FILES)/$(EXEC_NAME_REGRESSION):$(SRC_TEST:%c=$(OBJ_FILES)/%o)
	$(CC)  -o $@ $^

$(OBJ_FILES)/%o: $(SRC_FILES)/%c
	$(CC)  $(opt) -c $< -o $@

txt: $(BIN_FILES)/$(FINAL_TARGET_TXT)

$(BIN_FILES)/$(FINAL_TARGET_TXT): $(SRC_NCURSES:%.c=$(OBJ_FILES)/%.o)
	$(CC) $+ -o $@ $(LDFLAGS) $(LIB_DIR) $(LIBS_TXT)

$(OBJ_FILES)/%.o: $(SRC_FILES)/%.c
	$(CC) -c $(CFLAGS) $(INCLUDE_FILES) $< -o $@

sdl: $(BIN_FILES)/$(FINAL_TARGET_SDL)

$(BIN_FILES)/$(FINAL_TARGET_SDL): $(SRC_SDL:%.c=$(OBJ_FILES)/%_sdl.o)
	$(CC) $+ -o $@ $(LDFLAGS) $(LIB_DIR) $(LIBS_SDL)

$(OBJ_FILES)/%_sdl.o: $(SRC_SDL_FILES)/%.c
	$(CC) -c $(CFLAGS) $(INCLUDE_FILES) $< -o $@

clean :
	rm $(OBJ_FILES)/*.o $(BIN_FILES)/$(EXEC_NAME_REGRESSION) $(BIN_FILES)/$(FINAL_TARGET_TXT) $(BIN_FILES)/$(FINAL_TARGET_SDL)

MemTest :
	valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes ./bin/Test_Reg

MemTxt :
	valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes ./bin/student_survivor_txt

MemSdl :
	valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes ./bin/student_survivor_sdl



